{include file="public/header" /}
<title>数据库还原</title>
</head>

<body>
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 系统设置 <span class="c-gray en">&gt;</span> 数据库还原
		<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
	</nav>
	<div class="page-container">
		<form id="export-form" method="post" action="{:url('export')}">
			<div class="mt-20">
				<table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
					<thead>
						<tr class="text-c">
							<th>备份名称</th>
							<th>卷数</th>
							<th>压缩</th>
							<th>数据大小</th>
							<th>备份时间</th>
							<th>状态</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						{notempty name="data"} {volist name="data" id="vo"}
						<tr class="text-c">
							<td>{$vo.time|date='Ymd-His',###}</td>
							<td>{$vo.part}</td>
							<td>{$vo.compress}</td>
							<td>{$vo.size|format_bytes}</td>
							<td>{$key}</td>
							<td>-</td>
							<td>
								<a class="btn btn-primary btn-xs btn-outline db-import" href="{:url('revert',['time'=>$vo['time']])}">还原</a>
								<a class="btn btn-danger btn-xs btn-outline" href="{:url('del',['time'=>$vo['time']])}">删除</a>
							</td>
						</tr>
						{/volist} {else /}
						<td colspan="7" class="text-center"> 暂无备份数据</td>
						{/notempty}
					</tbody>
				</table>

			</div>

		</form>

		<div id="pageNav" class="pageNav"></div>
	</div>
	{include file="public/footer" /}
	<script type="text/javascript">
		$(function() {

			$(".db-import").click(function() {
				var self = this,
					status = ".";
				$.get(self.href, success, "json");
				window.onbeforeunload = function() {
					return "正在还原数据库，请不要关闭！";
				};
				return false;

				function success(data) {
					if(data.code) {
						if(data.data.gz) {
							data.msg += status;
							if(status.length === 5) {
								status = ".";
							} else {
								status += ".";
							}
						}
						$(self).parent().prev().text(data.msg);
						if(data.data.part) {
							$.get(self.href, {
								"part": data.data.part,
								"start": data.data.start
							}, success, "json");
						} else {
							window.onbeforeunload = function() {
								return null;
							};
						}
					} else {
						layer.alert(data.msg, 0);
					}
				}
			});
		});
	</script>